
package com.itheima.kafka.listener;
import com.alibaba.fastjson.JSON;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Map;


@Component
public class HelloListener {
  /*  @KafkaListener(topics = "Topic")
    public void handleMsg(ConsumerRecord<?,?> record){
        System.out.println("消息key=" + record.key());
        System.out.println("消息value="+record.value());
    }*/
    @KafkaListener(topics = "Topic")
    public void handleMsg(String record){
        System.out.println("消息value="+record);
    }

    @KafkaListener(topics = "map")
    public void receiverMessage(String msg) {
        System.out.println(msg);
        Map map = JSON.parseObject(msg, Map.class);
        System.out.println(map.get("name"));

    }

}
